﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WcMatch.Consts;
using WcMatch.Models;

namespace WcMatch.Controllers
{
    [Route("[controller]/[action]")]
    [ApiController]
    public class MultFormController : ControllerBase
    {
        EthnicKindContext _ethnicKindContext;
        DistrictContext _districtContext;
        UniversityDivisionContext _universityDivisionContext;
        EmploymentTypesCxt _emCxt;
        IndustryKindCxt _industryKindCxt;

        public MultFormController(EthnicKindContext ethnicKindContext, 
                                  DistrictContext districtContext,
                                  EmploymentTypesCxt employmentTypes,
                                  IndustryKindCxt industryCxt,
                                  UniversityDivisionContext universityDivisionContext)
        {
            _ethnicKindContext = ethnicKindContext;
            _districtContext = districtContext;
            _universityDivisionContext = universityDivisionContext;
            _emCxt = employmentTypes;
            _industryKindCxt = industryCxt;
        }

        [HttpGet]
        public IEnumerable<EthnicKind>? GetEthnicKinds()
        {
            return _ethnicKindContext.EthnicKinds;
        }

        [HttpGet]
        public IEnumerable<District>? GetDistricts(int pid)
        {
            return _districtContext.Districts.Where(s => s.PId == $"{pid}");
        }

        [HttpGet]
        public IEnumerable<UniversityDivision>? GetUniDivsions(int pid)
        {
            return _universityDivisionContext.UniversityDivisions.Where(s => s.PId == pid);
        }

        [HttpGet]
        public IEnumerable<EmploymentTypes>? GetEmTypes()
        {
            return _emCxt.EmTypes;
        }

        [HttpGet]
        public IEnumerable<IndustryKinds>? GetIndustries()
        {
            return _industryKindCxt.Industries;
        }

        [HttpGet]
        public IActionResult GetOriType()
        {
            return Ok(GlobalDefines.OriganizationTypes);
        }

        [HttpGet]
        public IActionResult ComPubJobApplyDic()
        {
            return Ok(GlobalDefines.ZpZtArr);
        }
    }
}
